<?php
namespace Manage\Controller;
use Think\Controller;

/**
 * Class WeatherController
 * @package Manage\Controller
 * 天气
 */
class WeatherController extends Controller {

    private $model_name = '';
    private $record_model = 'WeatherchangeLog';



    public function log_index(){
        $this->display();
    }

    public function log_get_all(){
        $list = get_date_grid($this->record_model);
        echo json_encode($list);
    }

    public function log_add(){
        $model = D($this->record_model);
        if(IS_POST){
            $data = filterInput($_POST);
            $model->addObj($data, 'id');
            $this->success(LANG('save_success'));
            return;
        }else if(IS_GET){


        }
        $this->display();
    }

    public function log_edit(){
        $model = D($this->record_model);
        if(IS_POST){
            $post_data = filterInput($_POST);

            $model->save($post_data);
            $this->success(LANG('save_success'));
            return;
        }else if(IS_GET){

        }
        $this->display();
    }

    public function log_deleteArray(){
        $data = filterInput($_POST);
        $ids = $data['ids'];
        $model = D($this->record_model);
        $item = $model->deleteArray($ids);
        if($item){
            echo json_encode(array('status'=>1));
        }else{
            echo json_encode(array('status'=>0));
        }
    }

    public function get_obj_log_json(){
        $id = I('get.id');
        $obj = D($this->record_model)->queryObj($id, 'id');
        echo $obj?json_encode($obj):json_encode(array('status'=> -1));
    }

    public function get_all_weather(){
        $map['facilities_id'] = array('eq', I('get.facilities_type'));
        $map['facilities_id'] = array('eq', I('get.facilities_id'));
        $list = D($this->model_name)->queryArray($map);
        echo json_encode($list);
    }
}